#include "ecb/base/Problem.h"
#include "Properties.h"

#include <sstream>

namespace ecb {

    Problem::Problem(const std::string& id, const std::string& name,
            int dimensions, scalar minimum, scalar maximum, bool minimization)
    : _properties(new Properties(id, name, dimensions, minimum, maximum, minimization)) { }

    Problem::~Problem() {
        delete _properties;
    }

    Properties* Problem::properties() const {
        return this->_properties;
    }
    
    bool Problem::isBetter(scalar a, scalar b) const{
        return _properties->isMinimization() ? a < b : a > b;
    }
    
    scalar Problem::worstObjectiveValue() const{
        return _properties->isMinimization() ? INFINITY : -INFINITY;
    }
    
//    bool Problem::isWorse(scalar a, scalar b) const{
//        return _properties->isMinimization() ? a >= b : a <= b;
//    }
    
    std::string Problem::toString() const{
        return this->_properties->toString();
    }
    
    std::string Problem::toXml() const{
        std::stringstream ss;
        ss << "<Problem " << _properties->toString() << " />";
        return ss.str();
    }




}
